<template>
  <div id="topnav">
    <el-menu class="el-menu-demo" mode="horizontal">
      <el-menu-item><router-link to="/list">主页</router-link></el-menu-item>
      <el-menu-item @click="isLogin">{{ $store.state.isLogin }}</el-menu-item>
    </el-menu>
  </div>
</template>

<script>
export default {
  methods: {
    isLogin() {
      var msg = this.$store.state.isLogin;
      if (msg == "退出") {
        this.$confirm("是否退出登录?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          //清空store，并清除sessionStorage中存储的store
          this.$store.commit("isLogin", "登录");
          localStorage.removeItem("vuex");
          this.$router.push("/");
        });
      }
    },
  },
};
</script>

<style></style>
